package com.linkstec.stormmonitor.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import com.linkstec.stormmonitor.common.util.ConfigUtil;

public class DbUtil {
	
	private static Connection conn = null;
	
	public static Connection getConnection()
	{
		if(conn == null)
		{
			try {
				Class.forName(ConfigUtil.getProperty("db.driver"));
				conn = DriverManager.getConnection(ConfigUtil.getProperty("db.url"), ConfigUtil.getProperty("db.username"), ConfigUtil.getProperty("db.password"));
			} catch (ClassNotFoundException | SQLException e) {
				e.printStackTrace();
			}
		}
		return conn;
	}
}